package com.jeesite.modules.rc.dao;

import com.jeesite.common.dao.CrudDao;
import com.jeesite.common.entity.Page;
import com.jeesite.common.mybatis.annotation.MyBatisDao;
import com.jeesite.modules.rc.entity.RcPerson;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 人才表DAO接口
 * @author ccz
 * @version 2025-03-24
 */
@MyBatisDao
public interface RcPersonDao extends CrudDao<RcPerson> {

    @Select("WITH RECURSIVE RegionHierarchy AS (\n" +
            "    SELECT dq_id, dq_name\n" +
            "    FROM dq_place\n" +
            "    WHERE dq_name = #{rcJiguan}\n" +
            "    UNION ALL\n" +
            "    SELECT p.dq_id, p.dq_name\n" +
            "    FROM dq_place p\n" +
            "    INNER JOIN RegionHierarchy rh ON p.dq_parent_id = rh.dq_id\n" +
            ")\n" +
            "SELECT rp.*\n" +
            "FROM rc_person rp\n" +
            "WHERE rp.rc_jiguan IN (\n" +
            "    SELECT dq_name\n" +
            "    FROM RegionHierarchy\n" +
            ");")
    List<RcPerson> findPersonData(@Param("rcJiguan") String rcJiguan);
}